package main

import (
	"fmt"
	"io"
	"log"
	"net"
	"os"
)

func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:8080")
	if err != nil {
		fmt.Println(err)
	}
	//
	go func() {
		io.Copy(os.Stdout, conn)
	}()

	mustCopy(conn, os.Stdin)
	tcpconn := conn.(*net.TCPConn)
	tcpconn.CloseWrite()
}

func mustCopy(w io.Writer, in io.Reader) {
	if _, err := io.Copy(w, in); err != nil {
		log.Fatal(err)
	}
}
